define(["jquery","comm/form/form.config","comm/form/form.comm"],function($,$config,$comm){
	var tpl = {};

	/**
	 * 初始化
	 */
	// 题型tpl的集合
	var questTypeInit = function(){
		var html = "";
		var questTypeArr = $config.getAllQuestType();
		for (var i=0; i < questTypeArr.length; i++) {
			var $quest = $config.getQuest(questTypeArr[i]);
			html += $quest.tpl(questTypeArr);
		}
		return html;
	}
	// 全部题型
	tpl.init = function(){
		var html = "";
		html += total();
		html += questTypeInit();
		return html;
	}

	/**
	 * tpl模板 total
	 */
	var total = function(){
		var questTypeArr = $config.getAllQuestType();
		var h = $comm.judgeLoadTpl(questTypeArr);
		return 	'<script id="tpl_form_total" type="text/html">'+
				'	<form id="{{formId}}" class="form-horizontal clearfix">'+ // formId
				'		{{each questions as value1 i}}'+
				'			{{if value1.templData}}'+
				'				<div class="form-tmp" data-tmplType="{{value1.tmplType}}" data-templVersionId="{{value1.templVersionId}}" data-contId="{{value1.contId}}" data-ptContId="{{value1.ptContId}}">'+ // contId:任务内容id(建档用); ptContId:任务内容实例id(任务用)
				'					{{each value1.templData as value i}}'+ h + '{{/each}}'+
				'				</div>'+
				'			{{else}}'+
				'				{{each value1.contList as value2 i}}'+
				'				<div class="form-tmp" data-tmplType="{{value2.tmplType}}" data-templVersionId="{{value2.templVersionId}}" data-contId="{{value2.contId}}" data-ptContId="{{value2.ptContId}}">'+
				'					{{each value2.templData as value i}}'+ h + '{{/each}}'+
				'				</div>'+
				'				{{/each}}'+
				'			{{/if}}'+
				'		{{/each}}'+
				'	</form>'+
				'</script>';
	}

	return tpl;
});